#pragma once

#include "rtda/heap/cp_memberref.h"
#include "rtda/heap/field.h"

namespace jvm {
namespace heap {

class FieldRef : public MemberRef {
private:
    std::shared_ptr<Field> m_pField;

public:
    FieldRef(std::shared_ptr<ConstantPool> pCp, const std::shared_ptr<classfile::ConstantMemberRefInfo> pMemberrefInfo);
    static std::shared_ptr<FieldRef> newFieldRef(std::shared_ptr<ConstantPool> pCp, const std::shared_ptr<classfile::ConstantFieldRefInfo> pFieldrefInfo);
    
    std::shared_ptr<Field> resolvedField();
    void resolveFieldRef();

private:
    static std::shared_ptr<Field> lookupField(std::shared_ptr<Class> pC, const std::string& name, const std::string& descriptor);
};

} // namespace heap
} // namespace jvm
